<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <title>医生列表</title>
  <meta name="renderer" content="webkit" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  <link rel="stylesheet" href="../../static/lib/layui/css/layui.css" media="all" />
  <link rel="stylesheet" href="../../static/css/admin.css" media="all" />
</head>

<body>
  <div id="TMM_app">
    <div class="layui-fluid">
      <div class="layui-card">
        <div class="layui-form layui-card-header tmm-admin-card-header-auto tmm-filter-form">
          <input type="hidden" id="duplicateImg">
          <input type="hidden" id="file_name">
          <input type="hidden" id="type" value="0">
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label" style="width:70px;">客户电话</label>
              <div class="layui-input-inline">
                <input type="text" name="phone" id="phone" placeholder="客户电话" autocomplete="off" class="layui-input" />
              </div>
            </div>
            <div class="layui-inline">
              <button class="layui-btn tmm-admin-btn-list" type="button" id="query" lay-submit="" lay-filter="LAY-app-contlist-search">
                搜索
              </button>
            </div>
          </div>
        </div>
        <div class="layui-card-body">
          <table id="tmm-doctors-table" lay-filter="tmm-order-duplicate" class="layui-table"></table>
          <script type="text/html" id="imgTpl">
            <img style="display: inline-block; height: 44px;" src= {{ d.image }}>
          </script>
          <script type="text/html" id="tmm-admin-app-cont-tagsbar">
              <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">查重结果反馈</a>
            </script>
        </div>
      </div>
    </div>
  </div>

  <script src="../../static/lib/layui/layui.js"></script>
  <script>
    layui
      .config({
        base: "../../static/js/"
      })
      .extend({
        index: "index"
      })
      .use(["index", "table", "rate"], function () {
        var $ = layui.$,
          admin = layui.admin,
          view = layui.view,
          table = layui.table,
          form = layui.form;

        $(".layui-btn.tmm-admin-btn-tags").on("click", function () {
          var type = $(this).data("type");
          active[type] ? active[type].call(this) : "";
        });


        table.render({
          elem: "#tmm-doctors-table",
          skin: 'nob',
          size: 'lg',
          height: 'full-150',
          even: true,
          page: true,
          limit: 10,
          limits: [10, 20, 50],
          url: "${path}/order/duplicateData",
          where:{
            phone:$("#phone").val()
          },
          cols: [[
              {field:'order_sn', title: '订单编号'},
              {field:'create_time', title: '提交时间',templet:function (d) {
                  if(d.create_time!=null && d.create_time!=''){
                      return d.create_time.substring(0,19)
                  }
                  return "空";
              }},
              {field:'phone', title: '用户电话'},
              {field:'goods_name', title: '产品名称'},
              {field:'inner_price', title: '产品总金额'},
              {field:'order_sn', title: '操作',toolbar:"#tmm-admin-app-cont-tagsbar"},
            ]],
          text:{none:"暂无数据"},
        });
        table.on("tool(tmm-order-duplicate)", function (t) {
          var n = t.data;
          switch (t.event){
              case 'edit':
                  layer.open({
                      type: 2,
                      area: ['650px', '350px'],
                      fixed: false, //不固定
                      maxmin: true,
                      content: '${path}/order/duplicateEdit?order_sn='+n.order_sn,
                      btn: ['提交', '取消'],
                      yes:function () {
                        if($("#type").val()==2 && $("#duplicateImg").val()==''){
                          layer.alert("请上传重单凭证",{icon:2});
                          return;
                        }
                          var index = layer.load(2);
                          $.ajax({
                              type:"post",
                              url:"${path}/order/duplicateVoucher",
                              dataType:"json",
                              data:{
                                  order_sn:n.order_sn,
                                  url:$("#duplicateImg").val(),
                                  type:$("#type").val(),
                                  file_name:$("#file_name").val(),
                              },
                              success:function(data){
                                  layer.close(index);
                                  if(data.code ==0){
                                      layer.alert(data.msg,{icon:1}, function(){
                                          location.reload();
                                      });
                                  }else{
                                      layer.alert(data.msg,{icon:2});
                                  }
                              },
                              error:function (data) {
                                  layer.close(index);
                              }
                          });
                          return false;
                      }
                  });
                  return;
          }
        });
          //查询
          $('#query').on('click', function(){
              table.reload('tmm-doctors-table', {
                  page: {
                      curr: 1 //重新从第 1 页开始
                  }
                  ,where: {
                      phone:$("#phone").val(),
                  }
              }, 'data');
          });
      });
  </script>
</body>

</html>